import { Injectable } from '@nestjs/common';
import { CreateRichTextDto } from '../dtos/create-rich-text.dto';
import { UpdateRichTextDto } from '../dtos/update-rich-text.dto';
import { UploadService } from './../../shared/upload/upload.service';

@Injectable()
export class RichTextService {
  constructor(private readonly uploadService: UploadService) {}
  create(createRichTextDto: CreateRichTextDto) {
    return 'This action adds a new richText';
  }

  findAll() {
    return `This action returns all richText`;
  }

  findOne(id: number) {
    return `This action returns a #${id} richText`;
  }

  update(id: number, updateRichTextDto: UpdateRichTextDto) {
    return `This action updates a #${id} richText`;
  }

  remove(id: number) {
    return `This action removes a #${id} richText`;
  }
  async uploadAvatar(file) {
    const { url } = await this.uploadService.upload(file);
    return { code: 200, data: url, msg: '上传成功' };
  }
}
